package com.ch.boundarycallbackdemo.repository

import com.ch.boundarycallbackdemo.api.NewsApi
import com.ch.boundarycallbackdemo.bean.NewsBean
import com.ch.boundarycallbackdemo.db.NewsBoundCallBack
import com.ch.boundarycallbackdemo.retrofit.RetrofitManager
import com.ch.boundarycallbackdemo.retrofit.RetrofitManager.await

object NewsRepository {
    private var mWebServiceApi: NewsApi =
        RetrofitManager.createServiceApi(NewsApi::class.java)

    suspend fun getNewsList(numberPager: Int): NewsBean {
        var map = HashMap<String, String>()
        map["key"] = "192a2e7da8467d5fd853b29677b373f9"
        map["page"] = "$numberPager"
        map["page_size"] = "${NewsBoundCallBack.PAGE_SIZE}"
        return mWebServiceApi.getNews(map).await()
    }
}